package cz.muni.fi.pa165.transfers;

import cz.muni.fi.pa165.dto.CustomerDTO;
import cz.muni.fi.pa165.entity.Customer;

/**
 * Class provides converting between Customer entity and DTO
 * 
 * @author <a href="mailto:vramik at redhat.com">Vlastislav Ramik</a>
 */
public class CustomerT {

    public static CustomerDTO entityToDTO(Customer customer){
        if (customer == null) {
            return null;
        }
        
        CustomerDTO customerDTO = new CustomerDTO();
        
        customerDTO.setId(customer.getId());
        customerDTO.setAccountNumber(customer.getAccountNumber());
        customerDTO.setAddress(customer.getAddress());
        customerDTO.setCity(customer.getCity());
        customerDTO.setCountry(customer.getCountry());
        customerDTO.setName(customer.getName());
        customerDTO.setZip(customer.getZip());
                
        return customerDTO;        
    }
    
    public static Customer dTOtoEntity(CustomerDTO customerDTO){
        if (customerDTO == null) {
            return null;
        }
        
        Customer customer = new Customer();
        
        customer.setId(customerDTO.getId());
        customer.setAccountNumber(customerDTO.getAccountNumber());
        customer.setAddress(customerDTO.getAddress());
        customer.setCity(customerDTO.getCity());
        customer.setCountry(customerDTO.getCountry());
        customer.setName(customerDTO.getName());
        customer.setZip(customerDTO.getZip());
                
        return customer;      
    }    
}
